/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rtype;

import java.awt.Image;
import java.awt.Rectangle;
import javax.swing.ImageIcon;

/**
 * The missile moves at constant speed.
 * When it hits the right border of the Board, it becomes invisible.
 * It is then removed from the ArrayList of missiles.
 * @author Administrator
 */
public class Missile {

    private int x,y;
    private Image image;
    boolean visible;

    private final int BOARD_WIDTH=390;
    private final int MISSLE_SPEED=2;

    public Missile(int x, int y) {
        ImageIcon ii=new ImageIcon("Image/missile.png");
        image=ii.getImage();
        visible=true;
        this.x=x;
        this.y=y;
    }

    public Image getImage() {
        return image;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    

    public boolean isVisible() {
        return visible;
    }

    public void move(){
        x+=MISSLE_SPEED;
        if(x>BOARD_WIDTH) visible=false;
    }

    public Rectangle getBound(){
        return new Rectangle(x, y, image.getWidth(null), image.getHeight(null));
    }
}
